Hard Real Time


While Linux has quickly emerged as a winning embedded operating system, the main reason has never been speed. In fact, some forms of embedded Linux, such as Lineo's popular Embedix, make Linux a "hard" RTOS — a Real Time Operating System — by combining it with a second kernel built for real-time work.

MontaVista Software, Inc., however, has been implementing Linux itself as an RTOS since the company was formed early last year, and has worked to improve the performance of the Linux kernel to the point where it qualifies — all by itself — as a "hard" real time OS.

As press time (September 9) for this issue, MontaVista has delivered what it claims is a hard real time Linux kernel, based on the current 2.4 code version. The company claims that this new kernel is fully preemptable, and provides a 30-fold improvement in performance over the 2.4 base. Claimed worst case application responsiveness will be in the hundreds of microseconds. In an interview for Embedded Linux Journal, James Ready, Montavista's President & CEO, said, "This isn't just a better embedded Linux. It's a better Linux."

Ready also explained that the code

Real Hard Time

MontaVista's announcement was not met with universal approval. Its most direct competitor, Utah-based Lineo, responded with a statement that included these points:

    "Through our acquisition and integration of Zentropix, Lineo has been delivering hard real-time Linux for more than a year now. We have real customers using our hard real-time solutions today in the areas of flight simulation, weather monitoring systems, heart monitoring systems, industrial controls and many others.

    "The Lineo real-time solution achieves guaranteed hard real-time microsecond response times today. This is very different from the "relatively fully preemptable kernel," announced by this competitor.

    "Lineo continues to actively support and promote real-time technologies. For more information about Lineo's real-time technologies, please visit http://www.lineo.com/products/realtime_linux/index.html.

    "Lineo also makes hard real-time available from our open source site (http://opensource.lineo.com/projects.html). Users can download a full-version of RTAI (real-time application interface) and AtomicRTAI from this site."

    At LinuxWorld in San Jose this year, Lineo announced it would integrate real-time technology into the Embedix SDK, which Lineo will ship in Q4 of this year.

MontaVista has written is publicly submitted for the review process that has constantly improved the Linux kernel since Linus Torvalds posted it on the Net nearly ten years ago. "We're being very careful here," he says." Part of the charm of Linux is that you can do whatever you want with it. However, we're being very humble. This is a prototype. As we announced, our source will be on our Web site, which is our tradition. And we are offering this as a starting point for a very good set of capabilities that we are suggesting, in the most humble way, that 2.5 should consider. Linus always says 'show me the code.' Well, we're obeying that rule. We think this is a significant improvement in Linux in general, and showing the community the code, for all to see and play with, is the right and only thing to do.

As for the new kernel itself, Ready explains that the real issue is not just responsiveness to interrupts, but preemptability. Also that making Linux preemptable involved leveraging the same engineering work that yields Symmetric Multi-Processing (SMP). "When people think of real time, they think of 'well, how fast does it respond to interrupts? But the weakness in Linux ... is that, in standard form, Linux is a non-preemptable kernel. That means some low-priority process might have just started a system call that will take Linux a long time to finish because it does complex things. What you want to do is make the operations in the Linux
Read the interviews with both Jim Ready and Lineo's Bryan Sparks in the curren Embedded Linux Journal
kernel itself interruptable and preemptable. The thing you want to do is stop doing the internal processing on that low-priority thing and switch over to the process level. It turns out that that process of breaking up the Linux kernel so it can leave off where it can leave where it was and come back, requires identifying sections inside the code where you can do that. This is the same thing you need to be able to do to run on multiple processors, because you want to have parallelism, where chunks of Linux run here and different chunks run there. It turns out that the same engineering investigation and thought process for SMP can be utilized to make the Linux kernel preemptable and very much more responsive. The good news is that it's Linux. It's a side effect of the SMP work. So we're not hacking out the middle of the kernel on this. We're just enabling, on a single processor, the SMP facilities, but not for SMP work, obviously, but to enable the responsiveness. And it works like a charm."

Hard Hat Linux is MontaVista's embeddeed Linux brand. The new version, which is expected to come out of peer review by January, will offer a real-time scheduler, which features deterministic real-time application selection and dispatching, without altering standard Linux scheduling. There will also be an optional interrupt accelerator, based on technology from RTLinux, which is a product of FSMLabs of Albuquerque, New Mexico. This has a 5x claimed interrupt responsiveness improvement.

The first prototype is for IA32 platforms and was available immediately at press time from ftp://ftp.mvista.com. A technical paper explaining MontaVista's real time developments is available at ftp://ftp.mvista.com/pub/Real-Time/2.4.0-test6/preempt.txt.

— Doc Searls